package com.itheima.tanhua.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.itheima.tanhua.api.db.QuestionsAPi;
import com.itheima.tanhua.mapper.QuestionsMapper;
import com.itheima.tanhua.pojo.db.Question;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author 芝士雪豹
 * @create 2022/9/28/19:07
 */
public class QuestionsAPiImpl implements QuestionsAPi {
    @Autowired
    private QuestionsMapper questionsMapper;
    @Override
    public Question findByUserId(Long userId) {
        QueryWrapper<Question> qw = new QueryWrapper<>();
        qw.eq("user_id",userId);
        return questionsMapper.selectOne(qw);
    }

    @Override
    public void save(Question question) {
        questionsMapper.insert(question);
    }

    @Override
    public void update(Question question) {
        questionsMapper.updateById(question);
    }

}
